//
//  OrderDeliveryItemFrame.m
//  JiaoX
//
//  Created by yinqy on 15/2/3.
//  Copyright (c) 2015年 北京娇羞科技有限公司. All rights reserved.
//

#import "OrderDeliveryItemFrame.h"

#define MARGIN_TOP 30 //

@implementation OrderDeliveryItemFrame

-(void)setDeliverItem:(DeliverItem *)deliverItem{
    _deliverItem = deliverItem;
    
    UIImage *image = [UIImage imageNamed:@"ic_order_delivery_fly"];
    _leftImageFrame = CGRectMake(JXPublicInset, MARGIN_TOP, image.size.width, image.size.height);
    
    CGFloat descX = CGRectGetMaxX(_leftImageFrame)+JXPublicInset;
    CGFloat descY = _leftImageFrame.origin.y;
    CGFloat descW = JXScreenW-descX-JXPublicInset;
    CGFloat descH = [deliverItem.context sizeWithFont:[UIFont systemFontOfSize:DESC_FONT_SIZE] constrainedToSize:CGSizeMake(descW, MAXFLOAT)].height;
    _rightDescFrame = CGRectMake(descX, descY, descW, descH);
    
    CGFloat timeX = descX;
    CGFloat timeY = CGRectGetMaxY(_rightDescFrame)+JXPublicInset;
    CGFloat timeW = descW;
    CGFloat timeH = [deliverItem.time sizeWithFont:[UIFont systemFontOfSize:TIME_FONT_SIZE] constrainedToSize:CGSizeMake(timeW, MAXFLOAT)].height;
    _rightTimeFrame = CGRectMake(timeX, timeY, timeW, timeH);
    
    CGFloat lineX = (image.size.width-LINE_WIDTH)*0.5+JXPublicInset;
    CGFloat lineY = 0;
    CGFloat lineW = LINE_WIDTH;
    CGFloat lineH = CGRectGetMaxY(_rightTimeFrame)+MARGIN_TOP;
    _leftLineFrame = CGRectMake(lineX, lineY, lineW, lineH);
    
    self.frame = CGRectMake(0, 0, JXScreenW, CGRectGetMaxY(_leftLineFrame));
}
@end
